﻿using Microsoft.Extensions.DependencyInjection;
using System.Data;
using Microsoft.Data.Sqlite;
using WinFormsMVVM.Services;
using WinFormsMVVM.ViewModels;

namespace WinFormsMVVM.IoC
{
    public static class IoCContainer
    {
        public static ServiceProvider Configure()
        {
            var services = new ServiceCollection();
            // 设置SQLite数据库路径
            services.AddSingleton<IDbConnection>(sp => new SqliteConnection("Data Source=./database.db"));
            services.AddSingleton<DatabaseInitializer>();
            services.AddTransient<IUserService, UserService>();
            services.AddSingleton<LoginViewModel>();

            return services.BuildServiceProvider();
        }
    }
}
